海康摄像头web无插件3.2,vue开发,Nginx代理IIS服务器 |
您所在的位置:网站首页 › 监控摄像头 sdk › 海康摄像头web无插件3.2,vue开发,Nginx代理IIS服务器 |
在vue中实现海康摄像头播放,采用海康web无插件3.2开发包,采用Nginx代理IIS服务器实现; 1 摄像头要求,支持websocket 2 Nginx反向代理的结构参考地址: https://blog.csdn.net/Vslong/article/details/118517641?spm=1001.2101.3001.6650.4&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-4-118517641-blog-123397690.pc_relevant_3mothn_strategy_recovery&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-4-118517641-blog-123397690.pc_relevant_3mothn_strategy_recovery&utm_relevant_index=4 3.1 在海康威视的官网进行下载开发包https://open.hikvision.com/download/5cda567cf47ae80dd41a54b3?type=10&id=4c945d18fa5f49638ce517ec32e24e24 (1)新建webVideo.js文件,assets/script/webVideo.js,内容如下: export function WebVideo() { this.g_iWndIndex = 0 this.szDeviceIdentify = '' this.deviceport = '' this.rtspPort = '' this.channels = [] this.ip = '' this.port = '80' this.username = '' this.password = '' this.init = function(ip, username, password) { this.ip = ip this.username = username this.password = password // var self = this // 检查插件是否已经安装过 // var iRet = WebVideoCtrl.I_CheckPluginInstall(); // if (-1 == iRet) { // alert("您还未安装过插件,双击开发包目录里的WebComponentsKit.exe安装!"); // return; // } // 初始化插件参数及插入插件 WebVideoCtrl.I_InitPlugin(454, 315, { szColorProperty: 'plugin-background:#102749; sub-background:#102749; sub-border:#18293c; sub-border-select:red', bWndFull: true, // 全屏 // iPackageType: 2, iWndowType: 1, //分屏 bNoPlugin: true, // 支持无插件 cbInitPluginComplete: function () { WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin"); } }); } // 登录 this.clickLogin = function () { var self = this if ("" == self.ip || "" == self.port) { return; } debugger self.szDeviceIdentify = self.ip + "_" + self.port; WebVideoCtrl.I_Login(self.ip, 1, self.port, self.username, self.password, { success: function (xmlDoc) { setTimeout(function () { console.log('登录成功'); self.getChannelInfo(); self.getDevicePort(); }, 10); setTimeout(function() { self.clickStartRealPlay() }, 500) }, error: function (status, xmlDoc) { console.log('登录失败'); } }); } // 退出 this.clickLogout = function() { var self = this self.channels = [] if (null == self.szDeviceIdentify) { return; } var iRet = WebVideoCtrl.I_Logout(self.szDeviceIdentify); if (0 == iRet) { self.getChannelInfo(); self.getDevicePort(); } } // 获取通道 this.getChannelInfo = function() { var self = this self.channels = [] if (null == self.szDeviceIdentify) { return; } // 模拟通道 WebVideoCtrl.I_GetAnalogChannelInfo(self.szDeviceIdentify, { async: false, success: function (xmlDoc) { var oChannels = $(xmlDoc).find("VideoInputChannel"); $.each(oChannels, function (i) { var id = $(this).find("id").eq(0).text(), name = $(this).find("name").eq(0).text(); if ("" == name) { name = "Camera " + (i { this.webVideo.init(this.hkvInfo.ip, this.hkvInfo.username, this.hkvInfo.password) this.webVideo.clickLogin() }) }, stopVideoPlay() { this.webVideo.clickStopRealPlay() this.webVideo.clickLogout() } } } .plugin { width: 500px; height: 300px; }(3)引用海康开发包 将海康开发包,放到Public文件下 在index.html文件中引用相关js文件,如下图 网站端口号为Nginx中配置的端口号9007 5 nginx环境部署 5.1 nginx配置海康无插件开发包中地址打开nginx.conf文件 WEB无插件开发包_20211014_20211019120439\nginx-1.10.2\conf\nginx.conf 修改内容如下, 本地IP为10.196.43.220,127.0.0.1/localhost都可换成10.196.43.220 本地IIS配置IP端口号:127.0.0.1:9007 Nginx反向代理为localhost:9008 http://10.196.43.220:9007 访问地址一定要是本机的IP:10.196.43.220 127.0.0.1/localhost访问都是不会显示视频画面 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |